#ifndef QPARAMPICKTREEVIEW_H
#define QPARAMPICKTREEVIEW_H

#include "core_global.h"

#include <QTreeWidget>
#include <QMap>

class QMachineValue;

enum enViewType
{
    VT_ONE,
    VT_MUL
};

class CORELIB_EXPORT QParamPickTreeView : public QTreeWidget
{
    Q_OBJECT
public:
    explicit QParamPickTreeView(enViewType type,QWidget *parent = 0);
    ~QParamPickTreeView();
    void    clear();

    void    init();

    void    set_checked(QMachineValue* value,bool checked);

    QList<QMachineValue*>   get_checked();

protected:
    void    resizeEvent(QResizeEvent *event);
    void    mouseReleaseEvent(QMouseEvent *event);
    void    drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const;
    void    contextMenuEvent(QContextMenuEvent *);
protected:
    friend class QParamItemDelegate;
signals:
    
protected slots:
    void    select_all();
    void    unselect_all();

    void    select_group();
    void    unselect_group();

    void    select();
    void    unselect();

    void    turn_select_group();
    void    turn_select_all();
protected:
    QMap<QString,QTreeWidgetItem*>      m_group_to_item;
    QMap<QTreeWidgetItem*,QString>      m_item_to_group;

    QMap<QTreeWidgetItem*,QMachineValue*> m_item_to_value;
    QMap<QMachineValue*,QTreeWidgetItem*> m_value_to_item;

    enViewType                          m_type;

    QTreeWidgetItem *m_checked_item;

    QIcon                               m_none_icon;
    QIcon                               m_some_icon;
    QIcon                               m_all_icon;
};

#endif // QPARAMPICKTREEVIEW_H
